package com.liaoye.hellocustomview.view;

import android.text.TextPaint;
import android.util.Log;

public class MutableForegroundColorSpan extends ForegroundColorSpan {

    private static final String TAG = "MutableForeground";
    private int alpha = 255;
    private int foregroundColor;

    public MutableForegroundColorSpan(int alpha, int color) {
        super(color);
        this.alpha = alpha;
        this.foregroundColor = color;
    }

    public void setForegroundColor(int foregroundColor) {
        Log.i(TAG, "setForegroundColor: " + foregroundColor);
        this.foregroundColor = foregroundColor;
    }

    public void setAlpha(int alpha) {
        this.alpha = alpha;
    }

    @Override
    public void updateDrawState(TextPaint ds) {
        super.updateDrawState(ds);
        ds.setColor(foregroundColor);
    }
}
